import os
import filetype
path = "C:/Users/Admin/Desktop/新建文件夹" #文件夹目录
files= os.listdir(path) #得到文件夹下的所有文件名称
i=0
j=0
ftyle=''
for file in files: #遍历文件夹
    if file[-1]=='c':
         with open( path + '/' + file, 'r' ) as f:
             i+=1
             while True:
                if f.readline() =='':
                    break
                i+=1
            
    if file[-1]=='y':
        with open( path + '/' + file, 'r',encoding = "utf-8" ) as f:
             j+=1
             while True:
                if f.readline() =='':
                    break
                j+=1
print('C程序共有：%d 行' %i)
print('Pyhon程序共有：%d 行'%j)

